$(document).ready(function(){	
	var rpath = getRootPath() + "/";
	
	$('#resetCap').click(function() {
		var timestamp = (new Date()).valueOf(); 
		$.getJSON(rpath + "user/resetCaptcha/"+timestamp, function(data) {
			$('#capImg').html(data['image']);
			$("#test").val('');
		});
	});
	
	$("#submitCheck").click(function(event) {
		var str = trim($("#password").val());
		if ((str.length > 15) || (str.length < 6)) {
			$("#msg").html("密码必须为6-15位");
			$("#msg").css("display", "block");
			$("#err").hide();
			event.preventDefault();
		}else{
			str = trim($("#test").val());
			if (str.length <= 0) {
				$("#msg").html("请输入验证码");
				$("#msg").css("display", "block");
				$("#err").hide();
				event.preventDefault();
			}else{
				str = trim($("#email").val());
				if (!((str.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
						&& (str.length <= 40))){
					$("#msg").html("请输入正确的邮箱地址");
					$("#msg").css("display", "block");
					$("#err").hide();
					event.preventDefault();
				}
			}
		}
	});
});